|
1
|
|
|
/*jslint |
|
2
|
|
|
indent: 4 |
|
3
|
|
|
*/ |
|
4
|
|
|
|
|
5
|
|
|
/*global |
|
6
|
|
|
google |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
function tileUrl(template, servers, coord, zoom) { |
|
11
|
|
|
'use strict'; |
|
12
|
|
|
|
|
13
|
|
|
var limit = Math.pow(2, zoom), |
|
14
|
|
|
x = ((coord.x % limit) + limit) % limit, |
|
15
|
|
|
y = coord.y, |
|
16
|
|
|
s = servers[(Math.abs(x + y)) % servers.length]; |
|
17
|
|
|
|
|
18
|
|
|
return template.replace(/%s/, s).replace(/%x/, x).replace(/%y/, y).replace(/%z/, zoom); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
function osmProvider(name) { |
|
23
|
|
|
'use strict'; |
|
24
|
|
|
|
|
25
|
|
|
return new google.maps.ImageMapType({ |
|
26
|
|
|
getTileUrl: function (coord, zoom) { |
|
27
|
|
|
return tileUrl("http://%s.tile.openstreetmap.org/%z/%x/%y.png", ["a", "b", "c"], coord, zoom); |
|
28
|
|
|
}, |
|
29
|
|
|
tileSize: new google.maps.Size(256, 256), |
|
30
|
|
|
name: name, |
|
31
|
|
|
alt: "OpenStreetMap", |
|
32
|
|
|
maxZoom: 18 |
|
33
|
|
|
}); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
function osmDeProvider(name) { |
|
38
|
|
|
'use strict'; |
|
39
|
|
|
|
|
40
|
|
|
return new google.maps.ImageMapType({ |
|
41
|
|
|
getTileUrl: function (coord, zoom) { |
|
42
|
|
|
return tileUrl("http://%s.tile.openstreetmap.de/tiles/osmde/%z/%x/%y.png", ["a", "b", "c"], coord, zoom); |
|
43
|
|
|
}, |
|
44
|
|
|
tileSize: new google.maps.Size(256, 256), |
|
45
|
|
|
name: name, |
|
46
|
|
|
alt: "OpenStreetMap (german style)", |
|
47
|
|
|
maxZoom: 18 |
|
48
|
|
|
}); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
function ocmProvider(name) { |
|
53
|
|
|
'use strict'; |
|
54
|
|
|
|
|
55
|
|
|
return new google.maps.ImageMapType({ |
|
56
|
|
|
getTileUrl: function (coord, zoom) { |
|
57
|
|
|
return tileUrl("http://%s.tile.opencyclemap.org/cycle/%z/%x/%y.png", ["a", "b", "c"], coord, zoom); |
|
58
|
|
|
}, |
|
59
|
|
|
tileSize: new google.maps.Size(256, 256), |
|
60
|
|
|
name: name, |
|
61
|
|
|
alt: "OpenCycleMap", |
|
62
|
|
|
maxZoom: 17 |
|
63
|
|
|
}); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
function thunderforestOutdoorsProvider(name) { |
|
68
|
|
|
'use strict'; |
|
69
|
|
|
|
|
70
|
|
|
return new google.maps.ImageMapType({ |
|
71
|
|
|
getTileUrl: function (coord, zoom) { |
|
72
|
|
|
return tileUrl("http://%s.tile.thunderforest.com/outdoors/%z/%x/%y.png", ["a", "b", "c"], coord, zoom); |
|
73
|
|
|
}, |
|
74
|
|
|
tileSize: new google.maps.Size(256, 256), |
|
75
|
|
|
name: name, |
|
76
|
|
|
alt: "Thunderforest Outdoors", |
|
77
|
|
|
maxZoom: 18 |
|
78
|
|
|
}); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
function opentopomapProvider(name) { |
|
83
|
|
|
'use strict'; |
|
84
|
|
|
|
|
85
|
|
|
return new google.maps.ImageMapType({ |
|
86
|
|
|
getTileUrl: function (coord, zoom) { |
|
87
|
|
|
return tileUrl("https://%s.tile.opentopomap.org/%z/%x/%y.png", ["a", "b", "c"], coord, zoom); |
|
88
|
|
|
}, |
|
89
|
|
|
tileSize: new google.maps.Size(256, 256), |
|
90
|
|
|
name: name, |
|
91
|
|
|
alt: "OpenTopoMap", |
|
92
|
|
|
maxZoom: 15 |
|
93
|
|
|
}); |
|
94
|
|
|
} |
|
95
|
|
|
|